home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / os2 / wuz12.zip / ZipStrip.Cmd < prev   
OS/2 REXX Batch file  |  1994-04-17  |  1KB  |  66 lines

  1. /* Compares current directory to zip file.          */
  2. /* Deletes files that no longer exist after confirmation. */
  3.  
  4. parse arg Name
  5. if Name='' then do
  6.   say "Usage: ZipStrip <zip-filename>"
  7.   say "Compares current directory to zip file."
  8.   say "Deletes files that no longer exist after confirmation."
  9.   exit(1)
  10. end
  11.  
  12. if Stream( Strip(Name,,'"'), 'C', 'QUERY EXISTS' ) = '' then do
  13.   say Name "not found."
  14.   exit 1
  15. end
  16.   
  17. '@unzip -l' Name '| rxqueue /fifo'
  18.  
  19. len = ''
  20. do while len \= 'LENGTH'
  21.   pull WholeLine
  22.   parse var WholeLine len . . FieldName .
  23. end
  24. pull Underline
  25.  
  26. do i=1 to queued()
  27.   pull WholeLine
  28.   parse var WholeLine len . . File.i .
  29.   if len = '------' then
  30.     count = i-1
  31.   else
  32.     File.i = Strip(File.i,,'^')
  33. end
  34. if Left(FieldName,4) \= "NAME" then do
  35.   say "I don't understand this format.  Name field's title is" FieldName
  36.   exit(1)
  37. end
  38.  
  39. z = 0
  40. do i=1 to count
  41.   if Stream( File.i, 'C', 'QUERY EXISTS' ) = '' then do
  42.     z = z+1
  43.     Deleted.z = File.i
  44.   end
  45. end
  46.  
  47. if z = count then do
  48.   say "None of the files in the archive exist.  Are you in the right directory?"
  49.   exit(1)
  50. end
  51.  
  52. if z>0 then do
  53.   DeleteList = ''
  54.   do i=1 to z
  55.     DeleteList = DeleteList Deleted.i
  56.   end
  57.   say "Preparing to remove:" DeleteList
  58.   Call CharOut ,"Okay? "
  59.   parse upper pull okay
  60.   if Left(okay,1)='Y' then do
  61.     '@zip -d' Name Strip(DeleteList)
  62.   end
  63.   else
  64.     say "Aborting ->" okay
  65. end
  66.